# coding:utf-8
import pymysql
from flask_wtf import FlaskForm
from wtforms import SubmitField, SelectField, TextAreaField
from wtforms.validators import Length

class ComplaintForm(FlaskForm):
    conn = pymysql.connect(
        host='127.0.0.1',
        user='root',
	password='123456',
        db='mytest',
        charset='utf8')
    cur = conn.cursor(cursor=pymysql.cursors.DictCursor)
    cur.execute('select id,name from student')
    students = cur.fetchall()
    cur.close()
    conn.commit()
    conn.close()
    students2 = []
    for i in range(len(students)):
        if students[i]['name'] == 'admin':
            continue
        item = (str(students[i]['id']), students[i]['name'])
        students2.append(item)
    student = SelectField(u'Complaints Student', choices=students2)
    body = TextAreaField(u'Complaints Content', validators=[Length(5, 300)])
    submit = SubmitField(u'Submit', )
